// pages/storePlace/storePlace.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    storeList:[
      {
        id:0,
        name:"联想服务中心软件园二期店",
        latitude: 24.486394,
        longitude: 118.181397,
        mark:[{
          id:0,
          latitude: 24.486394,
          longitude: 118.181397,
          iconPath: '/images/icon/user/location.png', 
          customCallout: {
            anchorY: 0,
            anchorX: 0,
            display: 'ALWAYS'
          },
        }],
        address:"福建省厦门市思明区厦门软件园软件园观日路24号楼",
        mobile:"0592-2228383",
        time:"周一至周日9:00-18:00"
      },
      {
        id:1,
        name:"联想客户服务中心(集美店)",
        latitude: 24.584246,
        longitude: 118.109742,
        mark:[{
          id:1,
          latitude: 24.584246,
          longitude: 118.109742,
          iconPath: '/images/icon/user/location.png', 
          customCallout: {
            anchorY: 0,
            anchorX: 0,
            display: 'ALWAYS'
          },
        }],
        address:"福建省厦门市集美区乐海南里266号",
        mobile:"0592-6531513",
        time:"周一至周日9:00-18:00"
      },
      {
        id:2,
        name:"联想服务中心故宫路店",
        latitude: 24.464992,
        longitude: 118.082587,
        mark:[{
          id:2,
          latitude: 24.464992,
          longitude: 118.082587,
          iconPath: '/images/icon/user/location.png', 
          customCallout: {
            anchorY: 0,
            anchorX: 0,
            display: 'ALWAYS'
          },
        }],
        address:"福建省厦门市思明区故宫路127-129号",
        mobile:"0592-2280111",
        time:"周一至周日9:00-18:00"
      },
      {
        id:3,
        name:"联想服务中心火炬园地铁站店",
        latitude: 24.511528,
        longitude: 118.11862,
        mark:[{
          id:3,
          latitude: 24.511528,
          longitude: 118.11862,
          iconPath: '/images/icon/user/location.png', 
          customCallout: {
            anchorY: 0,
            anchorX: 0,
            display: 'ALWAYS'
          },
        }],
        address:"福建省厦门市湖里区嘉禾路601号火炬园地铁站里面1号出入口通道店面(联想客户服务中心)",
        mobile:"0592-5251227",
        time:"周一至周日9:00-18:00"
      }
    ],
    showModalStatus:false,
    latitude: 24.511528,
    longitude: 118.11862,
    mark: [
      {
        latitude: 24.511528,
        longitude: 118.11862,
        iconPath: '/images/icon/user/location.png', 
        customCallout: {
          anchorY: 0,
          anchorX: 0,
          display: 'ALWAYS'
        },
      }
    ],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
  },

  powerDrawer: function (e) {
    var currentStatu = e.currentTarget.dataset.statu;
    if(currentStatu=="open"){
      var storeId=e.currentTarget.dataset.storeid;
      console.log("storeId",storeId)
      this.setData({
        latitude: this.data.storeList[storeId].latitude,
        longitude: this.data.storeList[storeId].longitude,
        mark:this.data.storeList[storeId].mark
      })
    }

    this.util(currentStatu)
  },
  util: function(currentStatu){
    /* 动画部分 */
    // 1：创建动画实例 
    var animation = wx.createAnimation({
      duration: 200, 
      timingFunction: "linear", 
      delay: 0
    });
    // 2：这个动画实例赋给当前的动画实例
    this.animation = animation;
    // 3：执行第一组动画：Y轴偏移240px后(盒子高度是240px)，停
    animation.translateY(240).step();
    // 4：导出动画对象赋给数据对象储存
    this.setData({
      animationData: animation.export()
    })
    // 5：设置定时器到指定时候后，执行第二组动画
    setTimeout(function () {
      // 执行第二组动画：Y轴不偏移，停
      animation.translateY(0).step()
      // 给数据对象储存的第一组动画，更替为执行完第二组动画的动画对象
      this.setData({
        animationData: animation
      })
      
      //关闭抽屉
      if (currentStatu == "close") {
        this.setData(
          {
            showModalStatus: false
          }
        );
      }
    }.bind(this), 200)
  
    // 显示抽屉
    if (currentStatu == "open") {
      this.setData(
        {
          showModalStatus: true
        }
      ); 
    }
  },


  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})